#ifndef __MY_I2C_H
#define __MY_I2C_H

#include "stdint.h"
#include "fsl_gpio.h"
#include "LPC804.h"

/*************************
		SCL_MCU -- PIO0_13
		SDA_MCU -- PIO0_17
**************************/
#define TMF8001_I2C_PORT 						 0U
#define TMF8001_I2C_SCL_PIN          13U
#define TMF8001_I2C_SDA_PIN          17U

enum
{
	GPIO_PIN_RESET = 0U,
	GPIO_PIN_SET = 1U,
};

#define TMF8001_I2C_SCL_HIGHT    		 GPIO_PinWrite(GPIO, TMF8001_I2C_PORT, TMF8001_I2C_SCL_PIN, GPIO_PIN_SET)
#define TMF8001_I2C_SCL_LOW      		 GPIO_PinWrite(GPIO, TMF8001_I2C_PORT, TMF8001_I2C_SCL_PIN, GPIO_PIN_RESET)
#define TMF8001_I2C_SDA_HIGHT    		 GPIO_PinWrite(GPIO, TMF8001_I2C_PORT, TMF8001_I2C_SDA_PIN, GPIO_PIN_SET)
#define TMF8001_I2C_SDA_LOW     		 GPIO_PinWrite(GPIO, TMF8001_I2C_PORT, TMF8001_I2C_SDA_PIN, GPIO_PIN_RESET)

#define TMF8001_I2C_SDA_Out      																											 	\
{																																												\
		gpio_pin_config_t TMF_RED_config = { .pinDirection = kGPIO_DigitalOutput};					\
		GPIO_PinInit(GPIO, TMF8001_I2C_PORT, TMF8001_I2C_SDA_PIN, &TMF_RED_config);					\
}																																												\

#define TMF8001_I2C_SDA_In       	   																										\
{																																												\
		gpio_pin_config_t TMF_RED_config = { .pinDirection = kGPIO_DigitalInput};						\
		GPIO_PinInit(GPIO, TMF8001_I2C_PORT, TMF8001_I2C_SDA_PIN, &TMF_RED_config);					\
}																																												\

#define Get_TMF8001_I2C_SDA          GPIO_PinRead(GPIO, TMF8001_I2C_PORT, TMF8001_I2C_SDA_PIN)

#define TMF8001_Address              0x82

void iic_delay_us(uint8_t time);
void TMF8001_I2C_Init(void);
void TMF8001_I2C_Start(void);
void TMF8001_I2C_Stop(void);
void TMF8001_I2C_Ack(void);
void TMF8001_I2C_NAck(void);
void TMF8001_I2C_Send_Byte(uint8_t Byte);
uint8_t TMF8001_I2C_Read_Byte(uint8_t ack);

uint8_t I2C_TMF8001_ReadByte(uint8_t Addr, uint8_t *Read_Buf, uint8_t Len);
void I2C_TMF8001_WriteByte(uint8_t Addr, uint8_t *Data_Com, uint8_t Len);
int crc8_compute(uint8_t *check_data,uint8_t num_of_data);
int shtc3_crc8_check(uint8_t *p,uint8_t num_of_data,uint8_t CrcData);
void TMF8001_Config(void);
float GetTemp_Humi_value(void);





#endif
